<?php

namespace app\common\validate;

use think\Validate;

class Agent extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'username' => 'require|regex:\w{3,30}|unique:agent',
        'nickname' => 'require',
        'password' => 'require|regex:\S{32}',
        'contacts'  =>'require',
        'mobile'  =>'require',
        'province'  =>'require',
        'city'  =>'require',
        'districts'  =>'require',
        'address'  =>'require',
        'bank_id'  =>'require',
        'bank_name'  =>'require',
        'bank_account'  =>'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['username', 'nickname', 'password','contacts','mobile','province','city','districts','address','bank_id','bank_name','bank_account'],
        'edit' => ['username', 'nickname','contacts','mobile','province','city','districts','address','bank_id','bank_name','bank_account'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'username' => '账号',
            'nickname' => __('Nickname'),
            'password' => __('Password'),
            'contacts' => '联系人',
            'mobile' => '手机号',
            'province' => '省份',
            'city' => '城市',
            'districts' => '县区',
            'address' => '详细地址',
            'bank_id' => '银行',
            'bank_name' => '账户名',
            'bank_account' => '银行卡号',
        ];
        $this->message = array_merge($this->message, [
            'username.regex' => __('Please input correct username'),
            'password.regex' => __('Please input correct password')
        ]);
        parent::__construct($rules, $message, $field);
    }

}
